﻿using Microsoft.EntityFrameworkCore.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using VisionCloud.Core.Model.Ms;
using VisionCloud.Domain.Repository.Interface.Ms;

namespace VisionCloud.Domain.Repository.Implement.Ms
{
    public class ProjectQualificationRateRepository : BaseRepository<ProjectQualificationRateView>, IProjectQualificationRateRepository
    {
        public IQueryable<ProjectQualificationRateView> QueryProjectQualificationRates(Guid CompanyId, Guid userId, bool isAdmin = false)
        {
            if (isAdmin)
            {
                return GetAll().Where(x => x.CompanyId == CompanyId);
            }
            else
            {
                return Db.ProjectQualificationRateView.Join(Db.MsUserToProjects, x => x.ProjectId, y => y.YunProjectGuid, (x, y) => new { x, y.YunUserGuid }).Where(x => x.YunUserGuid == userId).Select(x => x.x);
            }
        }
    }
}